import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    token: '',
    roles: []
  }),
  actions: {
    setToken(token) {
      this.token = token
    },
    logout() {
      this.token = ''
      this.roles = []
    }
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'library_user',
        storage: localStorage,
        paths: ['token']
      }
    ]
  }
})
